package org.baicaixiaozhan.springbootwebdemo1.util;

import com.google.common.io.ByteStreams;
import com.google.common.io.CharSource;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;

/**
 * DESC: IO 流工具类
 *
 * @author baicaixiaozhan
 * @since 2021/1/29
 */
public class IOUtils {

    /**
     * {@link InputStream} 转换为 {@link Reader}
     *
     * @param inputStream
     * @return reader
     * @throws IOException
     */
    public static Reader convertToReader(InputStream inputStream) throws IOException {
        byte[] buffer = ByteStreams.toByteArray(inputStream);
        return CharSource.wrap(new String(buffer)).openStream();
    }
}
